package com.atguigu1.core.operator

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 *
 * @description: xxx
 * @time: 2021-03-12 18:13
 * @author: baojinlong 
 **/
object Spark02Map {


  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("rdd")
    val sparkContext = new SparkContext(conf)
    val rdd: RDD[String] = sparkContext.textFile("datas/apache.log")
    // 将长的字符串转化成短字符串
    val mapRdd: RDD[String] = rdd.map(
      line => {
        val strings: Array[String] = line.split(" ")
        strings(6)
      }
    )
    mapRdd.collect().foreach(println)
    sparkContext.stop()
  }

}
